<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="图床API接口集合">
    <meta name="author" content="">
    <title>超简图床</title>
    <!-- Bootstrap core CSS -->
    <link href="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <!-- Custom styles for this template -->
    <link href="cover.css" rel="stylesheet">
</head>

<body style="overflow: hidden;">
<div style="position: absolute;top: 0;left: 0;right: 0;bottom: 0; z-index: 99999;">
    <div class="site-wrapper">
        <div class="site-wrapper-inner">
            <div class="cover-container">
                <div class="masthead clearfix">
                    <div class="inner">
                        <h3 class="masthead-brand"><a class="title" href="/">超简图床</a></h3>
                        <nav>
                            <ul class="nav masthead-nav">
                                <li><a href="index.html">主页</a></li>
                                <li class="active"><a href="setting.html">系统设置</a></li>
                                <!--<li><a href="api.html">Api接口</a></li>-->
                                <li><a href="file.html">API接口</a></li>
                            </ul>
                        </nav>
                    </div>
                </div>

                <div class="inner cover">
                    <h1 class="cover-heading">系统配置</h1>
                    <p class="lead">

                    <form id="set" action="/conf/update" target="#">
                        <div class="form-group">
                            <div class="input-group">
                                <div class="input-group-addon">运行模式</div>
                                <select class="form-control" id="type" name="type">
                                    <option value="1" >搜狗CDN（需配置代理域名）</option>
                                    <option value="2">SM.MS(需要注册,免费5G空间)</option>
                                    <option value="3">6间房CDN(无需配置,会掉图)</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="sr-only" for="msToken">SM.MS(需要注册,免费5G空间)Token</label>
                            <div class="input-group">
                                <div class="input-group-addon">SM 密钥</div>
                                <input type="text" class="form-control" id="msToken" name="msToken" placeholder="SM.MS密钥">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="sr-only" for="key">通讯密钥</label>
                            <div class="input-group">
                                <div class="input-group-addon">API密钥</div>
                                <input type="text" class="form-control" name="key" id="key" placeholder="调用Api时使用的通讯密钥">
                            </div>
                        </div>
                        <br><br>
                        <button type="submit" class="btn btn-lg btn-default" >保存配置</button>

                        <button type="button" class="btn btn-lg btn-default" onclick="loginOut()">退出登录</button>
                    </form>
                    </p>
                </div>

                <div class="mastfoot">
                    <div class="inner">
                        <p>本网站由超简图床程序提供服务, Copyright © 2020</p>
                    </div>
                </div>

            </div>

        </div>

    </div>
</div>

<div id="bj" style="position: absolute;top: 0;left: 0;right: 0;bottom: 0;"></div>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>
    function getConfig(){
        $.get("/conf/getConfig",function (data) {
            if (data.code == 1){
                $("#type").val(data.data.type);
                $("#key").val(data.data.key);
                $("#msToken").val(data.data.msToken);
            } else{
                dologin();
            }

        });
    }

    function dologin() {
        var pass = prompt("请输入管理员密码");
        if (pass=="" || pass == null){
            window.location.href = "index.html";
            return;
        }
        $.post("/login","pass="+pass,function (data) {
            if (data.code == 1){
                alert(data.msg);
                getConfig();
            } else{
                alert(data.msg);
                dologin();
            }
        });
    }

    function loginOut(){
        location.href = '/logout';
    }

    getConfig();

    $("#set").submit(function (event) {
        event.preventDefault();
        $.post({
            url: "/conf/update",
            type: "POST",
            data: new FormData(this),
            contentType: false,
            processData: false,
            success: function (data) {
                alert(data.msg);
            }
        });
    });
</script>

<script src="particles.js"></script>
<script>

    particlesJS('bj',
        {
            "particles": {
                "number": {
                    "value": 50,
                    "density": {
                        "enable": true,
                        "value_area": 1000
                    }
                },
                "color": {
                    "value": "#ffffff"
                },
                "shape": {
                    "type": "circle",
                    "stroke": {
                        "width": 0,
                        "color": "#000000"
                    },
                    "polygon": {
                        "nb_sides": 5
                    },
                    "image": {
                        "src": "img/github.svg",
                        "width": 100,
                        "height": 100
                    }
                },
                "opacity": {
                    "value": 0.5,
                    "random": false,
                    "anim": {
                        "enable": false,
                        "speed": 1,
                        "opacity_min": 0.1,
                        "sync": false
                    }
                },
                "size": {
                    "value": 5,
                    "random": true,
                    "anim": {
                        "enable": false,
                        "speed": 40,
                        "size_min": 0.1,
                        "sync": false
                    }
                },
                "line_linked": {
                    "enable": true,
                    "distance": 150,
                    "color": "#ffffff",
                    "opacity": 0.4,
                    "width": 1
                },
                "move": {
                    "enable": true,
                    "speed": 6,
                    "direction": "none",
                    "random": false,
                    "straight": false,
                    "out_mode": "out",
                    "attract": {
                        "enable": false,
                        "rotateX": 600,
                        "rotateY": 1200
                    }
                }
            },
            "interactivity": {
                "detect_on": "canvas",
                "events": {
                    "onhover": {
                        "enable": false,
                        "mode": "grab"
                    },
                    "onclick": {
                        "enable": true,
                        "mode": "push"
                    },
                    "resize": true
                },
                "modes": {
                    "grab": {
                        "distance": 400,
                        "line_linked": {
                            "opacity": 1
                        }
                    },
                    "bubble": {
                        "distance": 400,
                        "size": 40,
                        "duration": 2,
                        "opacity": 8,
                        "speed": 3
                    },
                    "repulse": {
                        "distance": 200
                    },
                    "push": {
                        "particles_nb": 4
                    },
                    "remove": {
                        "particles_nb": 2
                    }
                }
            },
            "retina_detect": true,
            "config_demo": {
                "hide_card": false,
                "background_color": "#b61924",
                "background_image": "",
                "background_position": "50% 50%",
                "background_repeat": "no-repeat",
                "background_size": "cover"
            }
        }
    );

    $(document).ready(function(){
        //获取所有接口
        $.get("/conf/apis", function(res){
            var str = '';
            for(var key in res){
                str += '<option value="'+key+'">'+res[key]+'</option>'
            }
            $("#type").html(str);
        });
    });
</script>

</body>
</html>
